﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Mail;

namespace QLMB.ViewModels
{
    public class MySendMail
    {
        public bool SendMail_Thankyou(string receiver)
        {
            MailMessage mail = new MailMessage();

            mail.To.Add(receiver);
            //mail.Bcc.Add(new MailAddress(""));
            mail.Subject = "Xac nhan Check In";

            mail.IsBodyHtml = true;

            string str = "<html>"
                       + "<P>WelCome Air Line</P>"
                       + "<P>Thanh Cong roi !</P>"
                       + "</html>";

            mail.Body = str;

            try
            {
                SmtpClient client = new SmtpClient();
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.EnableSsl = true;
                client.Host = "smtp.gmail.com";
                client.Port = 587;

                // setup Smtp authentication
                NetworkCredential credentials = new NetworkCredential("xuantien.uit@gmail.com", "08520404");
                client.UseDefaultCredentials = false;
                client.Credentials = credentials;

                client.Send(mail);

                return true;
            }
            catch (Exception)
            {
                return false;
            }

        }

        public MySendMail()
        {
            // TODO: Complete member initialization
        }
    }
}